<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>itf_expectation</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="LIBIT Documentation"
HREF="index.html"><LINK
REL="UP"
HREF="refmanual.html"><LINK
REL="PREVIOUS"
TITLE="itf_differentiate"
HREF="man.itf-differentiate.html"><LINK
REL="NEXT"
TITLE="itf_mul"
HREF="man.itf-mul.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>LIBIT Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="man.itf-differentiate.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="man.itf-mul.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="MAN.ITF-EXPECTATION"
></A
>itf_expectation</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN9555"
></A
><H2
>Name</H2
>itf_expectation&nbsp;--&nbsp;expectation operator</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN9558"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN9559"
></A
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;it/math.h&gt;
      </PRE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>double itf_expectation</CODE
>( double x, it_function_args(itf_expectation) *args
        );</CODE
></P
><P
></P
></DIV
></DIV
><H2
>DESCRIPTION</H2
><P
>The function <CODE
CLASS="FUNCTION"
>itf_expectation</CODE
> returns the expectation of the an it_function <CODE
CLASS="FUNCTION"
>f</CODE
> defined as the integral of t*f(t) over the interval. This is also sometimes called the first moment of the function <CODE
CLASS="FUNCTION"
>f</CODE
>. The argument <CODE
CLASS="PARAMETER"
>x</CODE
> corresponds to the upper bound of this integral.  The expectation of the function is approximated by computing the value of the function at various positions between <CODE
CLASS="PARAMETER"
>a</CODE
> and <CODE
CLASS="PARAMETER"
>x</CODE
> and using the Romberg method to compute a fast and accurate approximation. The expectation operator has the following parameters, passed through the <CODE
CLASS="PARAMETER"
>args</CODE
> argument.</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN9575"
></A
><H3
>Function parameters</H3
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>a</DT
><DD
><P
>         The lower bound of the integral.
      </P
></DD
><DT
>function</DT
><DD
><P
>         The function on which to compute the expectation.
      </P
></DD
><DT
>args</DT
><DD
><P
>         The parameters of the function.
      </P
></DD
></DL
></DIV
></DIV
><H2
>RETURN VALUE</H2
><P
>    Not really applicable. See the example below.
   </P
><H2
>EXAMPLE</H2
><PRE
CLASS="PROGRAMLISTING"
>&#13;#include &lt;math.h&gt;

...

/* declare the expectation parameters */
it_function_args(itf_expectation) expectation_args;

/* compute the expectation of the identity function,  */
/* limited to the range [0,sqrt(2)]                   */
/* (this defines a valid p.d.f.)                      */
expectation_args.function = itf_identity;
expectation_args.args = NULL;
expectation_args.a = 0.0;
itf_integrate_romberg(sqrt(2.0), &#38;expectation_args);</PRE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="man.itf-differentiate.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="man.itf-mul.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>itf_differentiate</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="refmanual.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>itf_mul</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>